import cv2 
import os
 
    
OldImgaepath = './image'
NewImgaepath = './image_new'
 
      
for Imagedir in os.listdir(OldImgaepath):    
    i = 0
    os.makedirs(NewImgaepath+'/'+Imagedir)
    for Imagefile in os.listdir(OldImgaepath+'/'+Imagedir):
        img = cv2.imread(OldImgaepath+'/'+Imagedir+'/'+Imagefile)         
        cv2.imwrite(NewImgaepath+'/'+Imagedir+'/'+'{}'.format(i)+'.jpg',img)
        i+=1
        img = cv2.rotate(img,cv2.ROTATE_90_CLOCKWISE)    
        cv2.imwrite(NewImgaepath+'/'+Imagedir+'/'+'{}'.format(i)+'.jpg',img)   
        i+=1
        img = cv2.rotate(img,cv2.ROTATE_90_COUNTERCLOCKWISE)    
        cv2.imwrite(NewImgaepath+'/'+Imagedir+'/'+'{}'.format(i)+'.jpg',img)   
        i+=1
        img = cv2.rotate(img,cv2.ROTATE_180)    
        cv2.imwrite(NewImgaepath+'/'+Imagedir+'/'+'{}'.format(i)+'.jpg',img)   
        i+=1
        img = cv2.flip(img,1)    
        cv2.imwrite(NewImgaepath+'/'+Imagedir+'/'+'{}'.format(i)+'.jpg',img)   
        i+=1    
        img = cv2.flip(img,0)    
        cv2.imwrite(NewImgaepath+'/'+Imagedir+'/'+'{}'.format(i)+'.jpg',img)   
        i+=1       

